Ext.define("core.appset.controller.AppSetController", {
	extend : "Ext.app.Controller",
	mixins : {
		suppleUtil : "core.util.SuppleUtil",
		messageUtil : "core.util.MessageUtil",
		formUtil : "core.util.FormUtil",
		treeUtil : "core.util.TreeUtil",
		gridActionUtil : "core.util.GridActionUtil"
	},
	init : function() {
		
		// 事件注册
		this.control({
					"panel[xtype=appsetgrid]" : {
						select : this.checkEdit,
						deselect : this.checkEdit

					},

					"panel[xtype=appsetgrid] button[ref=searchbutton]" : {
						beforeclick : function(btn) {
							var grid = btn.up("panel[xtype=appsetgrid]");
							var store = grid.getStore();
							// Ext.Msg.alert('提示',btn.getText());
							var text = Ext.getCmp('sgroupid').getValue();
							store.clearFilter();
							store.filter("groupbh", text);
							// alert(text);
							return false;
						}
					},
					"panel[xtype=appsetgrid] button[ref=resetbutton]" : {
						beforeclick : function(btn) {
							var grid = btn.up("panel[xtype=appsetgrid]");
							var store = grid.getStore();
							// Ext.Msg.alert('提示',btn.getText());
							// var text = Ext.getCmp('sgroupid').getValue();

							Ext.getCmp('sgroupid').setValue("");
							store.clearFilter();
							// alert(text);
							return false;
						}
					}

				});
	},
	views : ["core.appset.view.MainLayout", "core.appset.view.AppSetGrid"

	],
	models : ["core.appset.model.AppSetModel"],
	stores : ["core.appset.store.AppSetStore"],
	checkEdit : function() {
		var grid = Ext.ComponentQuery.query("panel[xtype=controllergrid]")[0];
		var btndetailcontroller = Ext.ComponentQuery
				.query("panel[xtype=controllergrid] button[ref=detailcontroller]")[0];
		if (btndetailcontroller == null) {
			return;
		}
		var num = grid.getSelectionModel().getSelection().length;
		btndetailcontroller.setDisabled(num != 1);

	}
});